package fr.louloutes.lolshooter;

import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

import android.os.Bundle;
import android.widget.TextView;

/**
 * @author Louloute Help Activity - Affiche une aide de jeu, expliquant les
 *         règles, le maniement et le comportemetn du jeu
 */
public class HelpAct extends LOLActivity
{

	/**
	 * Converts an input stream to a string
	 * 
	 * @param is The {@code InputStream} object to read from
	 * @return A {@code String} object representing the string for of the input
	 * @throws IOException Thrown on read failure from the input
	 */
	public String inputStreamToString( InputStream is ) throws IOException
	{
		StringBuffer sBuffer = new StringBuffer();
		DataInputStream dataIO = new DataInputStream( is );
		String strLine = null;
		while ( ( strLine = dataIO.readLine() ) != null )
		{
			sBuffer.append( strLine + "\n" );
		}
		dataIO.close();
		is.close();
		return sBuffer.toString();
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate( Bundle savedInstanceState )
	{
		Utils.Log( "Help onCreate", this );
		super.onCreate( savedInstanceState );
		setContentView( R.layout.help );

		InputStream helpFile = getResources().openRawResource(
				R.raw.lolshooter_help );
		try
		{

			TextView helpText_v = ( TextView ) findViewById( R.id.textView_helpText );
			String strHelpFile = inputStreamToString( helpFile );
			helpText_v.setText( strHelpFile );
		} catch ( Exception e )
		{
			Utils.Log( "InputStreamToString erreur", this );
		}
	}

	@Override
	public void onStart()
	{
		Utils.Log( "Help onStart", this );
		super.onStart();
	}

	@Override
	public void onResume()
	{
		Utils.Log( "Help onResume", this );
		super.onResume();
	}

	@Override
	public void onPause()
	{
		Utils.Log( "Help onPause", this );
		super.onPause();
	}

	@Override
	public void onStop()
	{
		Utils.Log( "Help onStop", this );
		super.onStop();
	}

	@Override
	public void onDestroy()
	{
		Utils.Log( "Help onDestroy", this );
		super.onDestroy();
	}

}